<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>系统编辑</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/libs/layui2.2.5/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/common.css">
    <link rel="icon" href="href="${pageContext.request.contextPath}/static/libs/uiframe/frame/static/image/code.png">
</head>
<body>
    <form class="layui-form" style="padding-top: 20px;padding-right: 20px;" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">系统名称：</label>
            <div class="layui-input-block">
                <input type="text" name="appName" value="${app.appName}"
                       autocomplete="off" placeholder="请输入系统名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录页面：</label>
            <div class="layui-input-block">
                <input type="text" name="loginPage" value="${app.loginPage}"
                       autocomplete="off" placeholder="系统登录页面" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">保护级别：</label>
            <div class="layui-input-block">
                <select name="protectionLevel" lay-filter="protectionLevel">
                    <option value="">请选择保护级别</option>
                    <option value="1" selected="selected">共用类型</option>
                    <option value="2">需要权限验证</option>
                    <option value="3">私有类型</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否锁定：</label>
            <div class="layui-input-block">
                <c:choose>
                    <c:when test="${app.locked == 'true'}">
                        <input type="radio" name="locked" value="true" title="是" >
                        <input type="radio" name="locked" value="false" title="否" checked="checked" >
                    </c:when>
                    <c:when test="${app.locked == 'false'}">
                        <input type="radio" name="locked" value="true" title="是" checked="checked" >
                        <input type="radio" name="locked" value="false" title="否" >
                    </c:when>
                    <c:otherwise>
                        <input type="radio" name="locked" value="true" title="是" >
                        <input type="radio" name="locked" value="false" title="否" checked="checked">
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序编号：</label>
            <div class="layui-input-block">
                <c:choose>
                    <c:when test="${menu.sortedNum != null}">
                        <input type="text" name="sortedNum" value="${app.sortedNum}"
                               placeholder="请输入排序编号" autocomplete="off" class="layui-input">
                    </c:when>
                    <c:otherwise>
                        <input type="text" name="sortedNum" value=0
                               placeholder="请输入排序编号" autocomplete="off" class="layui-input">
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述：</label>
            <div class="layui-input-block">
                <textarea name="description" value="${app.description}"
                          placeholder="请输入描述内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="roleadd">提 交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重 置</button>
            </div>
        </div>
    </form>

<script type="text/javascript" src="${pageContext.request.contextPath}/static/libs/layui2.2.5/layui.js"></script>
<script>
    var appId = '${app.roleId}';

    layui.use(['form','layer'],function(){
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;

            //监听提交
        form.on('submit(roleadd)', function(data){
            var formData = data.field,url;
            if(appId == ""){
                url = '${pageContext.request.contextPath}/sys/app/appcreate';
            }else{
                appId = '${pageContext.request.contextPath}/sys/app/appupdate?appid=' + appId;
            }
            $.ajax({
                type:'post',
                dataType:'json',
                url:url,
                data:{
                    appId:appId,
                    appName:formData['appName'],
                    loginPage:formData['loginPage'],
                    protectionLevel:formData['protectionLevel'],
                    locked:formData['locked'],
                    sortedNum:formData['sortedNum'],
                    address:formData['address']
                },
                success:function (data) {
                    layer.msg(data.status);
                    window.parent.layIndex = null;
                    window.parent.closeAllLayer_App();
                },
                error:function (error) {
                    console.log(error);
                }
            });
            return false;
        });
    })
</script>
</body>
</html>
